Kettle = Widget.extend({
	ctor:function(){
		this._super();
		this.init();
		this.setTag(TAG_KETTLE_ALL);
	},
	init:function(){
		this.body = new Button(this, 10, TAG_KETTLE, "#kettle.png", this.callback,this);
		
		var label=new Button(this.body,10,TAG_KETTLE,"#label.png",this.callback,this);
		label.setPosition(this.body.width*0.5,this.body.height*0.5);
		
		var flow_right=new Button(this.body,10,TAG_FLOW_RIGHT,"#flow_right.png",this.callback,this);
		flow_right.setPosition(cc.p(5, this.body.height*0.99));
		flow_right.setRotation(45);
		flow_right.setAnchorPoint(cc.p(1,1));
		flow_right.setOpacity(0);
	},
	showFlow:function(){
		var flow_right=this.body.getChildByTag(TAG_FLOW_RIGHT);
		var fadein=cc.fadeIn(0.1);
		var fadeout=cc.fadeOut(0.1);
		flow_right.runAction(cc.sequence(fadein,cc.rotateBy(1,5),cc.delayTime(1),fadeout));
	},
	callback:function(p){
		var func=cc.callFunc(function() {
			gg.flow.next();
		},this);
		var action=gg.flow.flow.action;
		switch (p.getTag()) {
		case TAG_KETTLE:
			if(p.getParent().getTag()==p.getTag()){
				p=p.getParent();
			}
			var ber=cc.bezierBy(1, [cc.p(-25,15),cc.p(-50, 25),cc.p(-155,30)]);
			var rotate=cc.rotateBy(1,-60);
			var beaker=ll.run.getChildByTag(TAG_BEAKER_ALL);
			var flow_right=this.body.getChildByTag(TAG_FLOW_RIGHT);
			if(action==ACTION_DO1){
				flow_right.setRotation(45);
				p.runAction(cc.sequence(ber,rotate,cc.callFunc(function() {
					beaker.showLine(action);
					this.showFlow();
				},this),cc.delayTime(2),rotate.reverse(),ber.reverse(),func));
			}else if(action==ACTION_DO2){
				flow_right.setRotation(45);
				p.runAction(cc.sequence(ber,rotate,cc.callFunc(function() {
					beaker.showLine(action);
					this.showFlow();
				},this),cc.delayTime(2),rotate.reverse(),ber.reverse(),func));
			}else{
				p.runAction(cc.sequence(ber,rotate,cc.callFunc(function() {
					beaker.showLine(action);
					this.showFlow();
				},this),cc.delayTime(2),rotate.reverse(),ber.reverse(),func));
			}
			break;
		default:
			break;
		}
	}
});